#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QThread>
#include <QLabel>
#include <QMutex>
#include <QWaitCondition>
#include <BlockingConcurrentQueue.h>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

typedef struct TestData {
    QString strData;
    QPoint pos;
}TestData;

class TestQueue: public QThread
{
    Q_OBJECT

public:
    TestQueue(QWidget *parent = nullptr)
        : QThread(parent)
    {

    }
    ~TestQueue(){}

    void pushDataToQueue(const TestData& data);

protected:
    void run() override;

signals:
    void signalMoveData(TestData);

private:
    void quitThread();

    QMutex m_lock;
    QWaitCondition condition;
    moodycamel::BlockingConcurrentQueue<TestData> m_queue;
    bool m_abort = false;
};


class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

public slots:
    void onMoveData(TestData);

private slots:
    void on_pushButton_clicked();

private:
    QLabel* MainWindow::createRectangle();

    Ui::MainWindow *ui;
    TestQueue m_testQueue;
};
#endif // MAINWINDOW_H
